<fieldset>
    <legend>条件搜索</legend>
    <form class="layui-form layui-form-pane form-search" action="{:request()->url()}" onsubmit="return false" method="get" autocomplete="off">
        <div class="layui-form-item layui-inline">
            <label class="layui-form-label">班级名称</label>
            <div class="layui-input-inline" style="width:120px;">
                <input name="name" value="{:input('name','')}" placeholder="请输入班级名称" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item layui-inline">
            <label class="layui-form-label">上课地点</label>
            <div class="layui-input-inline" style="width:120px;">
                <input name="addr" value="{:input('addr','')}" placeholder="请输入上课地点" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item layui-inline">
            <input type="hidden" name="class_id" value="{$class_id}" />
            <button class="layui-btn layui-btn-primary"><i class="layui-icon">&#xe615;</i> 搜 索</button>
        </div>
        <div class="layui-form-item layui-inline">
            <input type="hidden" name="upload-box" value="" />
            <button name="btn-import" data-title="上传文件" data-file="btn"  data-field="upload-box"
                    class="layui-btn margin-left-10" type="button">
                <i class="fa fa-cloud-upload"> </i>
                <span> 导入班级信息</span>
            </button>
            <a target="_blank" style="position:absolute;right:16px;top:29px;"
               href="/excel/endclassgroup.xlsx">下载模板文件</a>
        </div>
    </form>
</fieldset>

<script>window.form.render()</script>
<script>
    $("button[name=btn-export]").click(function () {
        var month = $("input[name=month]").val();
        var origin = $("input[name=origin]").val();
        location.href = '/cms/eduenroll/export.html?origin='+origin+"&month="+month;
    });
    $("input[name=upload-box]").change(function () {
        var url = $(this).val();
        var class_id = $("input[name=class_id]").val();
        $.ajax({type : "POST",url : "/cms/edugroup/import.html",data : {"url":url,"class_id":class_id},
            success : function(result) {
                if(result.code==1){
                    layer.msg(result.info, {time: 3000});
                    location.reload();
                }else{
                    layer.msg(result.info, {time: 3000});
                }
            },error : function(e){
                layer.msg(e.responseText, {time: 5000});
            }
        });
    });
</script>